import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LayoutDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ConstrainedBoxDemo(),
          Container(
            height: 10,
          ),
          AspectRationDemo(),
          StackDeme(),
          Container1(),
        ],
      ),
    );
  }
}

class AspectRationDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return AspectRatio(
      aspectRatio: 16 / 1,
      child: Container(
        color: Colors.yellow,
      ),
    );
  }
}

class ConstrainedBoxDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ConstrainedBox(
      constraints: BoxConstraints(minHeight: 10, maxWidth: 20),
      child: Container(
        color: Colors.yellow,
      ),
    );
  }
}

class StackDeme extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Stack(
      alignment: Alignment.bottomCenter,
      children: [
        SizedBox(
          width: 200,
          height: 300,
          child: Container(
            alignment: Alignment(0.5, 0),
            decoration: BoxDecoration(
              color: Colors.orange,
              borderRadius: BorderRadius.circular(8),
            ),
            child: Icon(
              Icons.abc,
              color: Colors.white,
              size: 32,
            ),
          ),
        ),
        SizedBox(
          height: 20,
        ),
        SizedBox(
          width: 100,
          height: 40,
          child: Container(
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8),
                gradient:
                    RadialGradient(colors: [Colors.cyanAccent, Colors.white])),
            child: Icon(
              Icons.brightness_2,
              color: Colors.red,
              size: 32,
            ),
          ),
        ),
        Positioned(
          right: 20,
          top: 10,
          child: Material(
            color: Colors.transparent,
            child: InkWell(
                child: Icon(
                  Icons.ac_unit,
                  color: Colors.white,
                  size: 32,
                ),
                splashColor: Colors.white.withOpacity(0.3),
                highlightColor: Colors.white.withOpacity(0.1),
                onTap: () {
                  debugPrint('Tap');
                }),
          ),
          // child: Icon(
          //   Icons.ac_unit,
          //   color: Colors.white,
          //   size: 32,
          // ),
        ),
        Positioned(
          right: 40,
          top: 30,

          child: Icon(
            Icons.ac_unit,
            color: Colors.white,
            size: 32,
          ),
        ),
      ],
    );
  }
}

class Container1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          IconBadge(
            Icons.pool,
            size: 60,
          ),
          IconBadge(
            Icons.pool,
          ),
          IconBadge(
            Icons.pool,
            size: 60,
          ),
        ],
      ),
    );
  }
}

class IconBadge extends StatelessWidget {
  final IconData icon;
  final double size;

  IconBadge(this.icon, {this.size = 32});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Icon(icon, size: size, color: Colors.white),
      width: size + 60,
      height: size + 60,
      color: Colors.deepPurpleAccent,
    );
  }
}
